﻿using SqlSugar;

namespace Zhaoxi.App.Common.Entity
{
    [SugarTable("User")]// 
    public class User
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//数据库是自增才配自增 
        public int Id { get; set; }

        [SugarColumn(ColumnName = "CompanyId", IsNullable = true)]
        public int? CompanyId { get; set; }

        [Navigate(NavigateType.ManyToOne, nameof(CompanyId))]
        public Company? CompanyInfo { get; set; }

        [SugarColumn(ColumnName = "UserName", IsNullable = true)]//数据库与实体不一样设置列名 
        public string? UserName { get; set; }

        [SugarColumn(ColumnName = "CreateTime", IsNullable = true)]
        public DateTime? CreateTime { get; set; }

        public int UserDetailId { get; set; }

        [Navigate(NavigateType.OneToOne, nameof(UserDetailId))]
        public UserDetail? UserDetailInfo { get; set; } //不能赋值只能是null

        [Navigate(typeof(UserRoleMapping), nameof(UserRoleMapping.UserId), nameof(UserRoleMapping.RoleId))]//注意顺序
        public List<Role> RoleList { get; set; } //不能赋值只能是null
    }
}